module SourcesHelper
  def sources_index_fields(options)
    %w[name kind url enabled? keywords languages actions]
  end
  def sources_format_field(obj, field, options)
    case field
    when "type" then obj.type.gsub(/Source$/, "")
    when "actions"
      link_to("Edit", edit_source_path(obj)) + " | " +
      link_to("Delete", source_path(obj), :method => :delete, :confirm => "Are you sure you want to delete the source '#{obj.name}'?")
    else obj.send(field)
    end
  end
  
  def sources_index_links(objs, options)
    [link_to("Create new source", new_source_path)]
  end
end